/*
 * IAudioRecorder.java
 *
 * Created on 2007��3��19��, ����1:48
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.zxh.audio;

import javax.sound.sampled.AudioFormat;

/**
 *
 * @author ��˶
 */
public interface IAudioRecorder 
{
    /**
     * Default AudioFormat with the folowing settings: Sampling rate = 44.1 kHz,
     * Sample Size = 16 bits, Num Channels = 2 (stareo), Frame Size = 4,
     * Frame Rate = 44.1 kHz (same as Sampling Rate), little endiain = false.
     * </br>
     * @see AudioFormat
     */
    public static final AudioFormat DEFAULT_AUDIO_FORMAT = new AudioFormat
    (
            AudioFormat.Encoding.PCM_SIGNED,
            44100.0f, //44.1 kHz sampling rate = CD quality audio
            16, //1 bytes, 8 bit audio (1 * 8 bit byte)
            1, //1 channels, stereo
            2, //frame size = number of bytes in a sample * number of channels = Default WAVE
            44100, //frame rate = sampling rate = Default WAVE
            false //little endian = Default WAVE
    );

    /**
     * Default Buffer Size used for recording. This is the amount to record in each
     * succesive read() call while recording.
     *
     * @see javax.sound.sampled.TargetDataLine#read
     */
    public static final int bufSize = 16384;


    /**
     * Starts recording
     *
     * @throws Exception
     */
    public void startRecording() throws Exception;

    /**
     * Stops recording or playback
     */
    public void stopRecording();

    /**
     * Clears the current recorded audio in buffer (if any)
     */
    public void reset();


    /**
     * @param format The AudioFormat to use for recording
     * @see AudioFormat
     */
    public void setAudioFormat(AudioFormat format);

    /**
     * @return the current AudioFormat used for recording
     * @see AudioFormat
     */
    public AudioFormat getAudioFormat();

    /**
     * Sets default audio format for recording
     */
    public void setDefaultAudioFormat();
}
